<?php
require_once 'classes/Database.php';
require_once 'classes/CDKManager.php';

$cdkManager = new CDKManager();

// 检查所有商品的CDK库存
$products = [
    1 => '游戏礼包A',
    2 => '游戏礼包B', 
    3 => '月卡',
    4 => '新手礼包'
];

foreach ($products as $productId => $productName) {
    $availableCDK = $cdkManager->getAvailableCDK($productId);
    $totalCDK = $cdkManager->getProductCDKCount($productId);
    $usedCDK = $cdkManager->getUsedCDKCount($productId);
    
    echo "商品: {$productName} (ID: {$productId})\n";
    echo "  - 总CDK数: {$totalCDK}\n";
    echo "  - 已使用: {$usedCDK}\n";
    echo "  - 可用: " . count($availableCDK) . "\n";
    echo "  - 可用CDK码: " . (count($availableCDK) > 0 ? implode(', ', array_column($availableCDK, 'code')) : '无') . "\n\n";
}

// 检查所有CDK码的状态
$allCDKs = $cdkManager->getAllCDKs();
echo "所有CDK码状态:\n";
foreach ($allCDKs as $cdk) {
    echo "CDK: {$cdk['code']}, 商品ID: {$cdk['product_id']}, 状态: {$cdk['status']}, 订单ID: {$cdk['order_id']}\n";
}
?>
